package com.durian.base.frame.easyrouter;

import android.content.Intent;
import androidx.fragment.app.Fragment;

/**
 * 说明：结果代理
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2018/6/2 17:41
 * <p/>
 * 版本：version 1.0
 */
public class ActivityResultFragment extends Fragment {

    private OnActivityResultListener mListener;

    public ActivityResultFragment(){}

    public void setActivityResultListener(OnActivityResultListener listener){
        mListener = listener;
    }

    @Override
    public void startActivityForResult(Intent intent, int requestCode) {
        super.startActivityForResult(intent, requestCode);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (mListener != null){
            ActivityResult result = new ActivityResult(requestCode,resultCode,data);
            mListener.onReceiveResult(result);
        }
        mListener = null;
    }

}
